package com.cqsw.controller;


import com.cqsw.entity.Goods;
import com.cqsw.model.Result;
import com.cqsw.service.goodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/goods")
@CrossOrigin
public class goodsController {
    private goodsService goodsService;

    @Autowired
    public goodsController(goodsService goodsService){
        goodsService.selectAllGoods();
    }

    @GetMapping("/getAll")
    public Result selectAllGoods(){
        List<Goods> selectAllGoods=goodsService.selectAllGoods();
        return new Result(200,"查询成功",selectAllGoods);
    }
    @GetMapping("/getType")
    public Result selectGoodsType(){
        List<Goods> selectGoodsType=goodsService.selectGoodsType();
        return new Result(200,"查询成功",selectGoodsType);
    }
    @PutMapping
    public Result addGoods(Goods goods){
        return new Result(200,"添加成功",goodsService.addGoods(goods));
    }
    @PostMapping
    public Result updateGoodMessage(Goods goods){
        return new Result(200,"修改成功",goodsService.updateGoodsMessage(goods));
    }
}
